﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vm="clr-namespace:MoXAML.Scrubber.ViewModel"
    xmlns:ms="http://namespaces.mindscape.co.nz/wpf"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
    xmlns:MVVM="clr-namespace:MoXAML.MVVM.Behaviors;assembly=MoXAML.MVVM" 
    xmlns:dlg="clr-namespace:MoXAML.MVVM.DependencyProperties;assembly=MoXAML.MVVM"
    mc:Ignorable="d"
    x:Class="MoXAML.Scrubber.ScrubberDialog"
    x:Name="Window"
    Title="Scrubber settings"
    dlg:DialogCloser.DialogResult="{Binding DialogResult}"
    Width="246" Height="244" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="ToolWindow">

    <Window.Resources>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="7,0,0,0" />
        </Style>

        <ControlTemplate x:Key="validationTemplate">
            <DockPanel>
                <TextBlock Foreground="Red" FontSize="20">*</TextBlock>
                <AdornedElementPlaceholder/>
            </DockPanel>
        </ControlTemplate>


        <Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip"
        Value="{Binding RelativeSource={x:Static RelativeSource.Self},
                        Path=(Validation.Errors)[0].ErrorContent}"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
	<Window.Background>
		<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.AppWorkspaceColorKey}}"/>
	</Window.Background>
    
    <Window.DataContext>
        <vm:ScrubberOptionsViewModel />
    </Window.DataContext>

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition Height="22.984"/>
            <RowDefinition Height="22.984"/>
            <RowDefinition Height="22.984"/>
            <RowDefinition Height="22.984"/>
            <RowDefinition Height="22.984"/>
            <RowDefinition Height="22.984"/>
            <RowDefinition Height="22.984" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="205"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <TextBlock TextWrapping="Wrap" Text="Attribute count tolerance" Grid.Row="0"/>
        <TextBlock TextWrapping="Wrap" Text="Reorder attributes" Grid.Row="1"/>
        <TextBlock Text="Reduce precision" Grid.Row="2" />
        <TextBlock Text="Precision" Grid.Row="3" />
        <TextBlock Text="Remove common TwoWay values" Grid.Row="4" />
        <TextBlock Text="Force line minimum" Grid.Row="5" />
        <TextBlock Text="Space count" Grid.Row="6" />
        <TextBlock Text="Convert tabs to spaces" Grid.Row="7" />

        <TextBox Text="{Binding AttributeCountTolerance, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True,UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Validation.ErrorTemplate="{StaticResource validationTemplate}" Style="{StaticResource textBoxInError}" Margin="0,0,7,0" VerticalAlignment="Center">
            <i:Interaction.Behaviors>
                <MVVM:NumericTextBoxBehavior AllowDecimal="False" AllowNegatives="False"/>
            </i:Interaction.Behaviors>
        </TextBox>
        <TextBox Text="{Binding Precision, Mode=TwoWay, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True,UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.Row="3" Validation.ErrorTemplate="{StaticResource validationTemplate}" Style="{StaticResource textBoxInError}" Margin="0,0,7,0" VerticalAlignment="Center">
            <i:Interaction.Behaviors>
                <MVVM:NumericTextBoxBehavior AllowDecimal="False" AllowNegatives="False"/>
            </i:Interaction.Behaviors>
        </TextBox>
        <TextBox Text="{Binding SpaceCount, Mode=TwoWay, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True,UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.Row="6" Validation.ErrorTemplate="{StaticResource validationTemplate}" Style="{StaticResource textBoxInError}" Margin="0,0,7,0">
            <i:Interaction.Behaviors>
                <MVVM:NumericTextBoxBehavior AllowDecimal="False" AllowNegatives="False"/>
            </i:Interaction.Behaviors>
        </TextBox>
        <CheckBox Content="" HorizontalAlignment="Left" d:LayoutOverrides="Height" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" IsChecked="{Binding ReorderAttributes}"/>
        <CheckBox Content="" HorizontalAlignment="Left" Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" IsChecked="{Binding ReducePrecision}"/>
        <CheckBox Content="" HorizontalAlignment="Left" Grid.Column="1" Grid.Row="4" VerticalAlignment="Center" IsChecked="{Binding RemoveCommonDefaults}"/>
        <CheckBox Content="" HorizontalAlignment="Left" Grid.Column="1" Grid.Row="5" VerticalAlignment="Center" IsChecked="{Binding ForceLineMinimum}"/>
        <CheckBox Content="" HorizontalAlignment="Left" Grid.Column="1" Grid.Row="7" VerticalAlignment="Center" IsChecked="{Binding ConvertTabsToSpaces}"/>
            <Grid Grid.Row="8" Grid.ColumnSpan="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.667*" />
                    <ColumnDefinition Width="0.333*"/>
                </Grid.ColumnDefinitions>
                <Button Content="OK" Height="22" Width="72" IsDefault="True" Command="{Binding SaveCommand}" HorizontalAlignment="Right"/>
                <Button Content="Cancel" Height="22" Width="72" Grid.Column="1" IsCancel="True" HorizontalAlignment="Right" Margin="0,4.056,2,4.056"/>
            </Grid>
    </Grid>
</Window>